package com.huike.game.Activity;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.huike.game.R;
import com.huike.game.fragment.game10Image;
import com.huike.game.fragment.game10Video;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.res.ResourcesCompat;
import androidx.fragment.app.FragmentTransaction;

public class GameActivity10 extends AppCompatActivity implements View.OnClickListener {

    private ImageView ivLeftImage;
    private TextView tvLeftText;
    private TextView tvContentTitle;
    private ImageView ivRigthImage;
    private TextView tvRightText;
    private TextView tvGame10Video;
    private TextView tvGame10Image;
    private LinearLayout llFragment;
    private game10Video video;
    private game10Image image;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_game10);

//        初始化id
        initIds();

        //初始化fragment
         video = new game10Video();
         image = new game10Image();

        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.replace(R.id.ll_fragment,video).commit();

        tvGame10Video.setOnClickListener(this);
        tvGame10Image.setOnClickListener(this);

    }

    private void initIds() {
        ivLeftImage = (ImageView) findViewById(R.id.iv_left_image);
        tvLeftText = (TextView) findViewById(R.id.tv_left_text);
        tvContentTitle = (TextView) findViewById(R.id.tv_content_title);
        ivRigthImage = (ImageView) findViewById(R.id.iv_rigth_image);
        tvRightText = (TextView) findViewById(R.id.tv_right_text);
        tvGame10Video = (TextView) findViewById(R.id.tv_game10_video);
        tvGame10Image = (TextView) findViewById(R.id.tv_game10_image);
        llFragment = (LinearLayout) findViewById(R.id.ll_fragment);

        ivRigthImage.setVisibility(View.GONE);
        tvRightText.setVisibility(View.GONE);
        tvContentTitle.setText("车辆违章");
        tvLeftText.setVisibility(View.GONE);
        ivLeftImage.setImageResource(R.drawable.tiao);
    }

    private Boolean isClick = true;
    @Override
    public void onClick(View view) {
        if(view == tvGame10Video){

            if(!isClick){
                isClick = true;
                Drawable back = ResourcesCompat.getDrawable(getResources(),R.drawable.tv_border,null);
                tvGame10Image.setBackground(back);
//                Drawable draw = ResourcesCompat.getDrawable(getResources(),R.drawable.tv_border_to,null);
                tvGame10Video.setBackgroundResource(R.drawable.tv_border_to);

                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.replace(R.id.ll_fragment,video).commit();

            }


        }else if(view == tvGame10Image){

            if(isClick){
                isClick = false;
                Drawable back = ResourcesCompat.getDrawable(getResources(),R.drawable.tv_border_to,null);
                tvGame10Image.setBackground(back);
                Drawable draw = ResourcesCompat.getDrawable(getResources(),R.drawable.tv_border,null);
                tvGame10Video.setBackground(draw);

                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.replace(R.id.ll_fragment,image).commit();
            }

        }
    }
}
